#!/bin/sh
if [ ! -d /lib/modules/`uname -r`/extra ]; then
	sudo mkdir /lib/modules/`uname -r`/extra
else
    echo "/lib/modules/`uname -r`/extra File exists"
fi

echo "cp helloworld_drv.ko /lib/modules/`uname -r`/extra"
sudo cp helloworld_drv.ko /lib/modules/`uname -r`/extra

sudo depmod

echo "modprobe helloworld_drv"
sudo modprobe helloworld_drv
# disable autoload
vdrm_drvblack=$(grep -w helloworld_drv /etc/modprobe.d/blacklist.conf)

if [ x"$vdrm_drvblack" = x"" ]
then
    echo ' ' | sudo -S cp /etc/modprobe.d/blacklist.conf /etc/modprobe.d/blacklist.conf.bak
    echo "# Don't load helloworld_drv drv kernel module on boot" | sudo -S tee -a /etc/modprobe.d/blacklist.conf
    echo "blacklist helloworld_drv" | sudo -S tee -a /etc/modprobe.d/blacklist.conf
    echo ' ' | sudo -S depmod
    echo ' ' | sudo -S ldconfig /usr/local/lib /usr/local/lib32
else
    echo "helloworld_drv is already in blacklist"
fi

if [ ! -d /lib/modules/`uname -r`/extra ]; then
	sudo mkdir /lib/modules/`uname -r`/extra
else
    echo "/lib/modules/`uname -r`/extra File exists"
fi


